/**
 * Created by 1 on 2017/1/4.
 */
(function(){
    "use strict";
    function HighScore(){
        this.highScore=0;
        this.canvas=new Canvas("highScore",100,70);
        this._init();
    }
    HighScore.prototype={
        constructor:HighScore,
        _init:function(){
            this.highScore=this._getScore();
            this._render();
        },
        _render:function(){
            this.canvas.drawText(this.highScore);
        },
        _setScore:function(value){
            window.localStorage.setItem("high-score",value);
        },
       _getScore:function(){
            return window.localStorage.getItem("high-score") || 0;
       },
        checkScore:function(score){
            if(score>this.highScore){
                this.highScore=score;
                this._setScore(this.highScore);
                this._init();
            }
        }
    };
    window.HighScore=HighScore;
})();